package shiro.test;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.Factory;

/**
 * @author <a href="mailto:ifonlymaster@163.com">ifonly</a>
 * @version 1.0 2015-12-29 11:56
 * @since JDK 1.6
 */
public class Main {

    public static void main(String[] args) {
        Factory<org.apache.shiro.mgt.SecurityManager> f = new
                IniSecurityManagerFactory("classpath:auth.ini");
        org.apache.shiro.mgt.SecurityManager s = f.getInstance();
        SecurityUtils.setSecurityManager(s);
        UsernamePasswordToken token = new UsernamePasswordToken("javass", "cc");
        token.setRememberMe(true);
        Subject currentUser = SecurityUtils.getSubject();
        currentUser.login(token);
        boolean flag = currentUser.isPermitted("p1");
        System.out.println("flag==" + flag);
    }

}
